﻿
@{
    Layout = "~/Areas/Admin/Views/Shared/_AccountLayout.cshtml";
    ViewBag.Title = "用户注册 - 果壳园";
    @model Nutshell.Blog.Model.ViewModel.UserRegister
}

@section style{
    
}

<h2 class="title">注册新用户</h2>
<div class="left">
    @using (Ajax.BeginForm("register", new AjaxOptions { HttpMethod = "Post", OnSuccess = "success", OnBegin = "begin", OnFailure = "failure" }))
    {
        @Html.AntiForgeryToken()
        @Html.ValidationSummary(true)
        <div class="ctrl-group">
            @Html.LabelFor(model => model.UserName)
            <div>
                @Html.TextBoxFor(model => model.UserName)
            </div>
            @Html.ValidationMessageFor(model => model.UserName, null, new { @class = "error" })
        </div>
        <div class="ctrl-group">
            @Html.LabelFor(model => model.Email)
            <div>
                @Html.TextBoxFor(model => model.Email)
            </div>
            @Html.ValidationMessageFor(model => model.Email, null, new { @class = "error" })
        </div>
        <div class="ctrl-group">
            @Html.LabelFor(model => model.Nickname)
            <div>
                @Html.TextBoxFor(model => model.Nickname)
            </div>
            @Html.ValidationMessageFor(model => model.Nickname, null, new { @class = "error" })
        </div>
        <div class="ctrl-group" style="margin-top:35px;">
            @Html.LabelFor(model => model.Password)
            <div>
                @Html.PasswordFor(model => model.Password)
            </div>
            @Html.ValidationMessageFor(model => model.Password, null, new { @class = "error" })
        </div>
        <div class="ctrl-group">
            @Html.LabelFor(model => model.Repassword)
            <div>
                @Html.PasswordFor(model => model.Repassword)
            </div>
            @Html.ValidationMessageFor(model => model.Repassword, null, new { @class = "error" })
        </div>
        <div style="border:none;text-align:center;margin:20px 0px 20px 0px;">
            <input type="submit" id="btnRegister" class="btn-submit" value="注册" />
            <p style="font-size:14px;padding-left:55px;">*点击 “注册” 按钮，即表示您同意并愿意遵守 <a href="#" style="text-decoration:underline;font-size:14px;color:#4688f1"> 用户协议</a>。</p>
        </div>
    }

</div>
<div class="right">
    <img src="http://account.cnblogs.com/images/registersideimg.png?v=SuVn_GWSEJByGrNm06GT-sxx_RW9nUtfd625myn_CsE">
</div>


@section script{
    <script>
        function success(data) {
            loaded();
            if (data.code == 0) {
                layer.alert('注册完成，请登录邮箱完成验证才能使用。', { icon: 6 });
            } else {
                layer.msg(data.msg, { icon: 5 });
            }
        }
        function begin() {
            loadding();
        }
        function failure() {
            loaded();
        }
        function loadding() {
            $("#btnRegister").attr("disabled", true);
            $("#btnRegister").addClass("btn-disable");
            $("#btnRegister").removeClass("btn-submit");
            $("#btnRegister").val("正在注册");
        }
        function loaded() {
            $("#btnRegister").removeAttr("disabled");
            $("#btnRegister").removeClass("btn-disable");
            $("#btnRegister").addClass("btn-submit");
            $("#btnRegister").val("注册");
        }
    </script>
}